var app = getApp()
var QQMapWX = require('../../utils/qqmap-wx-jssdk.js');
Page({
  data: {
    objarr: [],
    height:0,
    width:0,
    currentTab: 1,
    wishid:''
  },
  onLoad: function (options) {
    var that = this;
    
    wx.getSystemInfo({
      success: function (res) {
        console.log(res);
        that.setData({
           width: res.windowWidth,
           height:res.windowHeight })
      }
    })
    if (!app.check_empty(options.id)) {
      this.setData({
        wishid:options.id
      })
    }
    
  },
  
  selectm(e) {
    let tab = e.currentTarget.dataset.tab
    if (this.data.currentTab != tab) {
      this.setData({
        currentTab: tab,
      })

    }
  },
  getmoney(e){
    this.setData({
      currentTab: e.detail.value,
    })
  },
  submit(){
    if (isNaN(this.data.currentTab)) {
      wx.showModal({
        title: '提示',
        content: '请输入有效金额',
      })
      this.setData({
        currentTab: ''
      })
    }else{
      if (!app.check_empty(this.data.currentTab)){
        let par = {
          wish_id: this.data.wishid,
          total_fee: this.data.currentTab
        }
        app.ajax("support_wish", par, (data, err) => {
          app.wxPays({
            data,
            success: function () {
              wx.showToast({
                title: '支付成功哈',
              })
              wx.navigateTo({
                url: '/pages/index/index',
              })
            },
            fail: function () {
              wx.showToast({
                title: '支付失败了呢',
              })
            }
          })
        })
      }else{
        wx.showToast({
          title: '金额不能是空',
        })
      }
    }
  }
  
});